<template>
	<view class="content">
<!--		<page-meta>-->
<!--			<navigation-bar background-color="#ffffff"></navigation-bar>-->
<!--		</page-meta>-->
		<view class="navTab">
			<block v-for="(item,index) in scrollList" :key="index">
				<view class="tab-item" :class="{'at-tab-item':current == index}" @click="tabChange(index)">
					{{item.name}}
				</view>
			</block>
			<view class="tab-bottom" :style="[{left:left+'px'},{width:width+'px'}]">
				<view class="xian" :style="{width:width/8+'px'}"></view>
			</view>
		</view>
		<swiper class="swiper" :current="current" @change="swiperChange">
			<swiper-item>
				<scroll-view scroll-y="true" class="scroll-view">
					<view class="box">
						<view class="list" v-for="i in 10">
							<image src="/static/index/ren.png" mode=""></image>
							<view class="right">
								<view class="name">此用户已卸载</view>
								<view class="time">2022.6.24</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view scroll-y="true" class="scroll-view">
					<view class="box">
						<view class="list" v-for="i in 10">
							<image src="/static/index/ren.png" mode=""></image>
							<view class="right">
								<view class="name">此用户已卸载</view>
								<view class="time">2022.6.24</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollList: [{
						name: '一级(5)'
					},
					{
						name: '二级(41)',
					}
				],
				current: 0,
				width: 0,
				left: 0,
				itemNode: '',
			};
		},
		onReady() {
			setTimeout(() => {
				const query = uni.createSelectorQuery().in(this);
				query.selectAll('.tab-item').boundingClientRect(data => {
					this.itemNode = data
					this.width = data[this.current].width
				}).exec();
			}, 500)

		},
		methods:{
			tabChange(index) {
				this.current = index
				this.left = this.itemNode[index].left
			},
			swiperChange(e) {
				console.log(e)
				let {
					current
				} = e.detail
				this.current = current
				this.left = this.itemNode[current].left
			},
		}
	}
</script>

<style lang="scss" scoped>
.content{
	display: flex;
	flex-direction: column;
	/* #ifdef APP-PLUS */
	height: 100vh;
	/* #endif */
	/* #ifndef APP-PLUS */
	height: calc(100vh - 98rpx);

	/* #endif */
	.navTab {
		display: flex;
		align-items: center;
		height: 98rpx;
		position: relative;
		background-color: #ffffff;

		.tab-item {
			width: 50%;
			text-align: center;
			font-size: 32rpx;
			font-weight: 500;
			color: #333333;
			// margin-right: 56rpx;
		}

		.at-tab-item {
			font-weight: bold;
			color: $uni-text-color;

		}

		.tab-bottom {
			position: absolute;
			bottom: 0;
			transition: left .2s linear;
			display: flex;
			justify-content: center;

			.xian {
				height: 8rpx;
				background: linear-gradient(90deg, #080808 0%, #080808 100%);
				border-radius: 60rpx;
			}
		}
	}
	.swiper{
		flex: 1;
		.scroll-view{
			height: 100%;
			.box{
				padding-top: 20rpx;
				.list{
					display: flex;
					align-items: center;
					height: 138rpx;
					padding-left: 30rpx;
          background: #ffffff;
					image{
						width: 98rpx;
						height: 98rpx;
						border-radius: 50%;
					}
					.right{
						padding-left: 24rpx;
						.name{
							font-size: 28rpx;
							font-weight: 400;
							color: #333333;
						}
						.time{
							font-size: 26rpx;
							font-weight: 400;
							color: #333333ad;
							margin-top: 8rpx;
						}
					}
				}
			}
		}

	}
}
</style>
